package com.ruoyi.production.service.impl.plug;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.order.domain.OrderAllocation;
import com.ruoyi.order.mapper.OrderAllocationMapper;
import com.ruoyi.production.domain.plug.PlugApply;
import com.ruoyi.production.mapper.plug.PlugApplyMapper;
import com.ruoyi.production.service.plug.IPlugApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 穴盘申请Service业务层处理
 *
 * @author ruoyi
 * @date 2021-07-11
 */
@Service
public class PlugApplyServiceImpl implements IPlugApplyService
{
    @Autowired
    private PlugApplyMapper plugApplyMapper;
    @Autowired
    private OrderAllocationMapper orderAllocationMapper;

    /**
     * 查询穴盘申请
     *
     * @param plugApplyId 穴盘申请ID
     * @return 穴盘申请
     */
    @Override
    public PlugApply selectPlugApplyById(Long plugApplyId)
    {
        return plugApplyMapper.selectPlugApplyById(plugApplyId);
    }

    /**
     * 查询穴盘申请列表
     *
     * @param plugApply 穴盘申请
     * @return 穴盘申请
     */
    @Override
    public List<PlugApply> selectPlugApplyList(PlugApply plugApply)
    {
        return plugApplyMapper.selectPlugApplyList(plugApply);
    }

    /**
     * 新增穴盘申请
     *
     * @param plugApply 穴盘申请
     * @return 结果
     */
    @Override
    public int insertPlugApply(PlugApply plugApply)
    {
        Long orderAllocationId = plugApply.getOrderAllocationId();
        OrderAllocation orderAllocation = orderAllocationMapper.selectOrderAllocationById(orderAllocationId);
        plugApply.setOrderId(orderAllocation.getOrderId());














        plugApply.setCreateTime(DateUtils.getNowDate());



        return plugApplyMapper.insertPlugApply(plugApply);
    }

    /**
     * 修改穴盘申请
     *
     * @param plugApply 穴盘申请
     * @return 结果
     */
    @Override
    public int updatePlugApply(PlugApply plugApply)
    {
        plugApply.setUpdateTime(DateUtils.getNowDate());
        return plugApplyMapper.updatePlugApply(plugApply);
    }

    /**
     * 批量删除穴盘申请
     *
     * @param plugApplyIds 需要删除的穴盘申请ID
     * @return 结果
     */
    @Override
    public int deletePlugApplyByIds(Long[] plugApplyIds)
    {
        return plugApplyMapper.deletePlugApplyByIds(plugApplyIds);
    }

    /**
     * 删除穴盘申请信息
     *
     * @param plugApplyId 穴盘申请ID
     * @return 结果
     */
    @Override
    public int deletePlugApplyById(Long plugApplyId)
    {
        return plugApplyMapper.deletePlugApplyById(plugApplyId);
    }
}
